#include<iostream>
#include <vector>
using namespace std;
class Solution {
public:
    int minCostClimbingStairs(vector<int>& cost) {
        int n = cost.size();
        vector<int> dp(n + 1);
         dp[0] = 0;
         dp[1] = 0;
         for (int i = 2; i <= n; i++) {
             dp[i] = min(dp[i - 1] + cost[i - 1], dp[i - 2] + cost[i - 2]);
        }
         return dp[n];
    }
};
class Solution2 {
public:
    int minCostClimbingStairs(vector<int>& cost) {
        int n = cost.size();
         int prev2 = 0;
         int prev1 = 0;
         int current;
         for (int i = 2; i <= n; i++) {
             current = min(prev1 + cost[i - 1], prev2 + cost[i - 2]);
             prev2 = prev1;
             prev1 = current;
        }
         return prev1;
    }
};
int main() {
    Solution sol;
    Solution2 sol2;
    vector<int>aa = { 1, 100, 1, 1, 1, 100, 1, 1, 100, 1 };
    cout<< sol.minCostClimbingStairs(aa)<<endl;
    cout<<sol2.minCostClimbingStairs(aa) <<endl;
    return 0;
}